package cn.com.joycode.nimble.springboot.autoconfigure;

import cn.com.joycode.nimble.springboot.filter.NbMsgFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

/**
 * @author Max Woods
 */

@Configuration
public class AutoConfiguration {

    @Bean
    public FilterRegistrationBean registerBaseFilter() {
        FilterRegistrationBean<NbMsgFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(new NbMsgFilter());
        registration.addUrlPatterns("/rest/*", "/api/*");
        registration.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);
        return registration;
    }
}